/**
 * $Revision: 1.0 $
 * $Author: Eric Yang $
 * $Date: Sep 8, 2009 12:24:31 AM $
 *
 * Author: Eric Yang
 * Date  : Sep 8, 2009 12:24:31 AM
 *
 */
package com.gooex.domain.base;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import com.gooex.domain.base.emun.DeliverType;
import com.gooex.domain.base.emun.PayType;
import com.gooex.domain.organization.Address;
import com.gooex.domain.organization.User;


/**
 * 订单客户
 * 
 * @author Eric Yang
 * @version 1.0
 */
public class OrderCustomer implements Serializable {

	/** PK */
	private String id;

	/** 对应用户 */
	private User user;

	/** 对应订单 */
	private Order order;

	/** 送货地址 */
	private Address address;

	/** 送货方式 */
	private DeliverType deliverType;

	/** 取货地点要求 */
	private String takeLocation;

	/** 付款方式 */
	private PayType payType;

	/** 所投票的供应商 */
	private OrderVendor votedVendor;

	/** 订单要求 */
	private List<OrderRequest> orderRequests = new ArrayList<OrderRequest>();

	/* ===========functions============================= */

	public void addOrderRequest(OrderRequest orderRequest) {
		orderRequests.add(orderRequest);
		orderRequest.setOrderCustomer(this);
	}

	/** 是否设置了地址薄 */
	public boolean hasSetAddress() {
		return address != null;
	}

	public boolean isVotedVendor(OrderVendor orderVendor) {
		return votedVendor != null && orderVendor != null && votedVendor.getId().equals(orderVendor.getId());
	}

	/* ===========setter/getter============================= */
	public List<OrderRequest> getOrderRequests() {
		return orderRequests;
	}

	public void setOrderRequests(List<OrderRequest> orderRequests) {
		this.orderRequests = orderRequests;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public Order getOrder() {
		return order;
	}

	public void setOrder(Order order) {
		this.order = order;
	}

	public Address getAddress() {
		return address;
	}

	public void setAddress(Address address) {
		this.address = address;
	}

	public OrderVendor getVotedVendor() {
		return votedVendor;
	}

	public void setVotedVendor(OrderVendor votedVendor) {
		this.votedVendor = votedVendor;
	}

	public DeliverType getDeliverType() {
		return deliverType;
	}

	public void setDeliverType(DeliverType deliverType) {
		this.deliverType = deliverType;
	}

	public String getTakeLocation() {
		return takeLocation;
	}

	public void setTakeLocation(String takeLocation) {
		this.takeLocation = takeLocation;
	}

	public PayType getPayType() {
		return payType;
	}

	public void setPayType(PayType payType) {
		this.payType = payType;
	}
}
